<style>
.ztree{
	border:1px solid #ccc;
}
</style>
<ul id="treeDemo" class="ztree"></ul>
<ul id="treeDemo1" class="ztree"></ul>
<script>
$(function(){
	
	/*
	*	浏览
	*/
	var setting = {
		view: {
			dblClickExpand: dblClickExpand
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
			onClick: onClick
		}
	};
	function dblClickExpand(treeId, treeNode) {
		return treeNode.level > 0;
	}

	function onClick(event, treeId, treeNode, clickFlag) {
		console.info(treeNode);
		console.info(clickFlag);
	}
		
	var zNodes =[
		{ id:1, pId:0, name:"根 Root", open:true},
		{ id:11, pId:1, name:"父节点 1-1", open:false},
		{ id:111, pId:11, name:"叶子节点 1-1-1"},
		{ id:112, pId:11, name:"叶子节点 1-1-2"},
		{ id:113, pId:11, name:"叶子节点 1-1-3"},
		{ id:114, pId:11, name:"叶子节点 1-1-4"},
		{ id:12, pId:1, name:"父节点 1-2", open:false},
		{ id:121, pId:12, name:"叶子节点 1-2-1"},
		{ id:122, pId:12, name:"叶子节点 1-2-2"},
		{ id:123, pId:12, name:"叶子节点 1-2-3"},
		{ id:124, pId:12, name:"叶子节点 1-2-4"},
		{ id:13, pId:1, name:"父节点 1-3", open:false},
		{ id:131, pId:13, name:"叶子节点 1-3-1"},
		{ id:132, pId:13, name:"叶子节点 1-3-2"},
		{ id:133, pId:13, name:"叶子节点 1-3-3"},
		{ id:134, pId:13, name:"叶子节点 1-3-4"},
		{ id:444, pId:11, name:"哈哈哈"}
	];
	
	/*
	*		多选
	*/
	
	var setting1 = {
		check: {
			enable: true,
			nocheckInherit: true
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
			onClick: onClick
		}
	};

	var zNodes1 =[
		{ id:1, pId:0, name:"中国", open:true},
		
		{ id:11, pId:1, name:"北京", open:true},
		{ id:111, pId:11, name:"海淀区"},
		{ id:112, pId:11, name:"东城区"},
		{ id:113, pId:11, name:"西城区"},
		
		{ id:22, pId:1, name:"河北", open:true},
		{ id:221, pId:22, name:"保定"},
		{ id:222, pId:22, name:"邯郸"}
	];

	function nocheckNode(e) {
		var zTree = $.fn.zTree.getZTreeObj("treeDemo1"),
		nocheck = e.data.nocheck,
		nodes = zTree.getSelectedNodes();
		if (nodes.length == 0) {
			alert("请先选择一个节点");
		}

		for (var i=0, l=nodes.length; i<l; i++) {
			nodes[i].nocheck = nocheck;
			zTree.updateNode(nodes[i]);
		}
	}
	
	$(document).ready(function(){
		$.fn.zTree.init($("#treeDemo"), setting, zNodes);
		$.fn.zTree.init($("#treeDemo1"), setting1, zNodes1);
		//$("#nocheckTrue").bind("click", {nocheck: true}, nocheckNode);
	});
})
</script>

